<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'jindu.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/hplus/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/hplus/css/plugins/bootstrap-table/bootstrap-table.min.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/hplus/css/plugins/sweetalert/sweetalert.css" />
<script type="text/javascript"
	src="${pageContext.request.contextPath}/hplus/js/jquery.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/hplus/js/bootstrap.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/hplus/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/hplus/js/plugins/sweetalert/sweetalert.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/hplus/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script>
	var aa=0;
	var cateval ;
		$(function(){
			 var category=window.location.search;
            //截取，获取获得category的具体值
            cateval = category.substring(category.lastIndexOf('=')+1, category.length);
            
            
            $.post("yjin.do?m=shu",{"zid":cateval},function(data){
					var r=eval("("+data+")");
					$("#you").text(r[0]);
					$("#liang").text(r[1]);
					$("#cha").text(r[2]);
			})
            
            
            
            $("#zeng").click(function(){
            	$("#myModalLabel").text("添加进度状况");
				$("#zhuang").val("请选中");
				
				aa=1;
            });
			$("#jin").bootstrapTable({
				url : "yjin.do?m=quan&zid="+cateval,
				//在底部启用分页
				height:650,
				striped : true,
				search : true,
				pagination : true,
				pageList: [5, 10, 15, 20],
				toolbar : "#btndiv",
				//隔行变色
				striped : true,
				//启用工具栏
				
				columns:[{
								field : 'id',
									title : 'id',
									visible : false
				
							},
						      {
						    	  	field : 'time',
									title : '日期',
									formatter : function(value, row, index) {
									return row.time+"<input type='hidden' class='z' value='"+row.zid+"'><input type='hidden' class='i' value='"+row.id+"'";
								}
						      },
						      {
						    	  field : 'status',
									title : '状况'
						      },{
						      	field:'problem',
						      	title:'问题',
						      
						      },{
						      	field:'zid',
						      	title:'zid',
						      	visible : false,
						      },{
						      	field:'xxxx',
						      	title:'操作',
						      	formatter : function(value, row, index) {
									return "<div class='xiu' data-toggle='modal' onclick='fu("+row.id+")' data-target='#myModal'>修改<div>";
								}
						      }
						]
			})
			$("#jin").on('click','div.xiu',function(){
			  $("#myModalLabel").text("修改进度状况");
			  var zhuang=$(this).parent().prev().prev().text();
			  var wen=$(this).parent().prev().text();
			  $("#zhuang").val(zhuang);
			  $("#wen").val(wen);
			  aa=2;
	    });
		})
		function fu(id){
			$("#ff").val(id);
		}
		function add(){
			if(aa==1){
				var zhuang=$("#zhuang").val();
				var wen=$("#wen").val();
				if(zhuang=="请选中" || wen==""){
					alert("请选择状况和问题！");
					return false;
				}
				var zid=cateval;
				$("#myModal").modal("hide");
				$.post("yjin.do?m=tian",{"zhuang":zhuang,"wen":wen,"zid":zid},function(data){
					var r=eval("("+data+")");
					$("#jin").bootstrapTable("load",r);
				})
				
			}else if(aa==2){
				var zhuang=$("#zhuang").val();
				var wen=$("#wen").val();
				if(zhuang=="请选中" || wen==""){
					alert("请选择状况和问题！");
					return false;
				}
				var id=$("#ff").val();
				var zid=$(".z").val();
				$("#myModal").modal("hide");
				$.post("yjin.do?m=xiu",{"zhuang":zhuang,"wen":wen,"id":id,"zid":zid},function(data){
					var r=eval("("+data+")");
					$("#jin").bootstrapTable("load",r);
				})
				 
			}
			
		}
		
	</script>
	
  </head>
  	
  <body>
  <input type="hidden" id="yin1" value="" />
  <input type="hidden" id="ff" value="">
  	 <div id="btndiv">
		<button type="button" id="zeng" class="btn" data-toggle="modal"
			data-target="#myModal">增加</button>
			
		<button type="button"  class="btn">优:<span id="you"></span></button>	
		<button type="button"  class="btn">良:<span id="liang"></span></button>
		<button type="button"  class="btn">差:<span id="cha"></span></button>
			
			
		<input type="button" class="btn"  onClick="javascript:history.go(-1);location.replace(document.referrer);"  value="返回" />
		
	</div>
	
    <table id="jin"></table>
    <div class="modal fade" id="myModal">
	  <div class="modal-dialog" role="document">
	    <div class="modal-content">
	      <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
	        <h4 class="modal-title" id="myModalLabel">添加进度状况</h4>
	      </div>
	      <div class="modal-body">
	        	 <form>
				  <div class="form-group">
				    <label for="name">状况</label>
				    <!-- <input type="text" class="form-control" id="name" placeholder="请输入收货人姓名"> -->
				    <select id="zhuang" class="form-control">
				    	<option value="请选中">请选中</option>
				    	<option value="优">优</option>
				    	<option value="良">良</option>
				    	<option value="差">差</option>
				    </select>
				  </div>
				  <div class="form-group">
				    <label for="address">问题</label>
				    <input type="text" id="wen" class="form-control">
				  </div>
				</form>
	      </div>
	      <div class="modal-footer">
	        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
	        <button onclick="add()" type="button" class="btn btn-primary">提交</button>
	      </div>
	    </div>
	  </div>
	</div>
  </body>
</html>
